#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="sql_helper"
__date__="2016/7/7"
__time__="10:08"
"""
import  MySQLdb
import conf
class mysql_helper(object):
    def __init__(self):
        self.__conn_dict=conf.conn_dict
    def get_one(self,sql,parms):
        conn =  MySQLdb.connect(**self.__conn_dict)
        cur = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        # 指定了sql执行结果返回字典类型

        cur.execute(sql,parms)
        data = cur.fetchone()
        cur.close()
        conn.close()
        return data
    def get_money(self,sql,parms):
        conn = MySQLdb.connect(**self.__conn_dict)
        cur = conn.cursor() # 默认sql执行结果返回列表。
        reCount = cur.execute(sql,parms)
        data = cur.fetchall()
        cur.close()
        conn.close()
        return data
    def insert_one(self,sql,parms):
        conn = MySQLdb.connect(**self.__conn_dict)
        cur = conn.cursor()
        reCount = cur.execute(sql,parms)
        conn.commit()
        cur.close()
        conn.close()


